package com.shimmer.CRUD;

import com.shimmer.dao.UserDao;
import com.shimmer.entity.User;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Package com.shimmer.CRUD
 * @Author shimmer
 * @Date 2020/8/16 15:29
 * @TODO
 */
public class UpdateServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        User user = new User();
        user.setId(Integer.parseInt(req.getParameter("id")));
        user.setName(req.getParameter("name"));
        user.setPassword(req.getParameter("password"));
        new UserDao().updateUser(user);
        
        resp.sendRedirect("retrieve");
    }
}
